StartsWith<T, U>
JSのstartsWith()の型版
code:ts
type StartsWith<T extends string, U extends string> =
T extends ${U}${string}
? true
: false;
例
code:ts
type cases = [
Expect<Equal<StartsWith<'abc', 'ac'>, false>>,
Expect<Equal<StartsWith<'abc', 'ab'>, true>>,
Expect<Equal<StartsWith<'abc', 'abc'>, true>>,
Expect<Equal<StartsWith<'abc', 'abcd'>, false>>,
Expect<Equal<StartsWith<'abc', ''>, true>>,
Expect<Equal<StartsWith<'abc', ' '>, false>>,
Expect<Equal<StartsWith<'', ''>, true>>,
];